package com.wlgc.entity;

import lombok.Data;

@Data
public class RestBean <T>{
    int code;//200成功，500失败
    String reason;
    T t;

    public RestBean() {
    }

    public RestBean(int code, String reason, T t) {
        this.code = code;
        this.reason = reason;
        this.t = t;
    }

    public RestBean(int code, String reason) {
        this.code = code;
        this.reason = reason;
    }

    public static <T> RestBean<T> success() {
        RestBean<T> restBean = new RestBean<T>();
        restBean.code = 200;
        return restBean;
    }

    public  static <T>  RestBean<T> success(T object){
        RestBean<T> restBean = new RestBean<T> ();
        restBean.t = object;
        restBean.code = 200;
        return restBean;
    }

    public static <T> RestBean<T> error(String msg) {
        RestBean restBean = new RestBean();
        restBean.reason = msg;
        restBean.code = 500;
        return restBean;
    }


}
